package com.zs4sdk.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.zs4sdk.common.Extra;
import com.zs4sdk.extra.Zs4GameCode;
import com.common.library.listener.OnProcessListener;

/**
 * 
 * function: 广播处理接收（用这种是不能确定所有分支都有发广播，unregisterReceiver会统一处理）
 * 
 * @ author: aXiBa
 */
public class SDKGameProcessReceiver extends BroadcastReceiver {
	
	private static final String TAG = SDKGameProcessReceiver.class.getSimpleName();
	
	String action;   // 监听代码
	
	OnProcessListener mOnProcessListener;    // 监听处理回调 
	
	public SDKGameProcessReceiver(String action, OnProcessListener mOnProcessListener) {
		this.action = action;
		this.mOnProcessListener = mOnProcessListener;
	}

	@Override
	public void onReceive(Context arg0, Intent intent) {
		String curAction = intent.getAction();
		if(null != curAction) {
			
			// 登录
			if(curAction.equals(action)) {
				if(null != mOnProcessListener) {
//					Log.d(TAG, "onReceive action" + curAction + "   code: " + intent.getIntExtra(Extra.INTENTKEY.CODE, Zs4GameCode.CANCEL));
					mOnProcessListener.finishProcess(intent.getIntExtra(Extra.INTENTKEY.CODE, Zs4GameCode.BACKTOGAME), intent.getExtras());
				}
			}
		}
	}

}
